package edu.zhang.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.zhang.dao.NoticeDAO;
import edu.zhang.dao.TypeDAO;
import edu.zhang.po.Notice;
import edu.zhang.po.Type;

@WebServlet("/Back/notice/NoticeUpdated")
public class NoticeUpdated extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		String title = request.getParameter("title");
		String concept = request.getParameter("title");
		String time = request.getParameter("time");

		Notice notice = new Notice();
		notice.setId(Integer.parseInt(id));
		notice.setTitle(title);
		notice.setConcept(concept);
		notice.setTime(time);

		NoticeDAO noticeDAO = new NoticeDAO();
		int i = noticeDAO.update(notice);

		if (i > 0) {
			request.getRequestDispatcher("/notice/NoticeController?option=list").forward(request, response);
		} else {
			response.sendRedirect("error.jsp");
		}
	}
}
